home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume15 / gnuplot2 / patch01 < prev    next >
Encoding:
Text File  |  1990-10-05  |  56.1 KB  |  2,295 lines

  1. Newsgroups: comp.sources.misc
  2. X-UNIX-From: eln272v@monu1.cc.monash.edu.au
  3. from: Russell Lang <rjl@monu1.cc.monash.edu.au>
  4. subject: v15i016: gnuplot 2.0 patch 1 (1 of 4)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 15, Issue 16
  8. Submitted-by: Russell Lang <rjl@monu1.cc.monash.edu.au>
  9. Archive-name: gnuplot2/patch01
  10.  
  11. # This is patch 1 to gnuplot 2.0.
  12.  
  13. # This patch is made up of 4 shar files.
  14. # The first shar file must by unshared with the command 
  15. # `sh gnuplot_patch1.sh1 -c` to allow it to overwrite the files
  16. # version.c, setshow.c, docs/doc2tex.c, docs/titlepage.ms and 
  17. # docs/titlepage.tex.  
  18.  
  19. # Russell Lang <rjl@monu1.cc.monash.edu.au>
  20.  
  21.  
  22.  
  23.  
  24. #! /bin/sh
  25. # This is a shell archive.  Remove anything before this line, then unpack
  26. # it by saving it into a file and typing "sh file".  To overwrite existing
  27. # files, type "sh file -c".  You can also feed this as standard input via
  28. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  29. # will see the following message at the end:
  30. #        "End of shell archive."
  31. # Contents:  README.patch1 version.c setshow.c docs docs/doc2tex.c
  32. #   docs/titlepage.ms docs/titlepage.tex
  33. # Wrapped by eln272v@monu1 on Tue Sep 18 14:52:44 1990
  34. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  35. if test -f README.patch1 -a "${1}" != "-c" ; then 
  36.   echo shar: Will not over-write existing file \"README.patch1\"
  37. else
  38. echo shar: Extracting \"README.patch1\" \(4083 characters\)
  39. sed "s/^X//" >README.patch1 <<'END_OF_README.patch1'
  40. XPatch 1 to gnuplot 2.0.
  41. X-----------------------
  42. X
  43. XThe files in this patch are
  44. X
  45. Xgnuplot_patch1.sh1:
  46. X    README.patch1 (this file)
  47. X    version.c
  48. X    setshow.c
  49. X    docs/doc2tex.c
  50. X    docs/titlepage.ms
  51. X    docs/titlepage.tex
  52. X
  53. Xgnuplot_patch1.sh2
  54. X    patch1a
  55. X
  56. Xgnuplot_patch1.sh3
  57. X    patch1b
  58. X
  59. Xgnuplot_patch1.sh4
  60. X    patch1c
  61. X
  62. X
  63. XTo apply this patch copy the files patch1a, patch1b and patch1c to the 
  64. Xgnuplot directory.  
  65. XOverwrite the original gnuplot files version.c, setshow.c, docs/doc2tex.c, 
  66. Xdocs/titlepage.ms and docs/titlepage.tex with the replacements in this patch.
  67. X
  68. XChange directory to the gnuplot directory, and then apply the patches
  69. Xwith the following commands:
  70. X
  71. X    patch -p < patch1a
  72. X    patch -p < patch1b
  73. X    patch -p < patch1c
  74. X
  75. XThen recompile gnuplot!
  76. X
  77. X
  78. XBuilding Gnuplot on Ultrix.
  79. X---------------------------
  80. X
  81. XChanges have been made to several term/*.trm files so that the Ultrix
  82. Xstandard cc compiler can now be used.  Use makefile.unx instead of 
  83. Xmakefile.ult.   makefile.ult may be deleted.
  84. X
  85. X
  86. XBuilding Gnuplot on RS/6000 AIX 3.1
  87. X-----------------------------------
  88. X
  89. XOne small source changes is needed to successfully compile gnuplot on AIX 3.1:
  90. X
  91. X   o Comment out the "extern char *malloc();" declaration in misc.c
  92. X
  93. XProper CFLAGS setting is -O -Dunix -DBCOPY -DBZERO -DGAMMA.
  94. X
  95. X
  96. XBuilding Gnuplot for X11
  97. X------------------------
  98. X
  99. XRead README.x11.
  100. X
  101. X
  102. XSignificant changes in this patch
  103. X---------------------------------
  104. X
  105. Xcommand.c:
  106. X    Fixed bug in replot command that arose under Turbo C.
  107. X        Added cd (change directory) and pwd (print working directory) 
  108. X        commands.
  109. Xgraphics.c:
  110. X    Fixed bugs in the ticmark-series code, by adding new functions 
  111. X    specifically for ticmark series.
  112. X    Corrected problems using user-defined ticmark sets with logscale.
  113. Xparse.c: 
  114. X    Catch a situation where no floating point exception occured and 
  115. X    yet the value computed was Inf (IEEE infinite).  
  116. X    This happens on the 3b1 when plotting x**-4 + x.
  117. Xpcgraph.asm:
  118. X    Changed the 'jmp _inter' to a far jump.
  119. Xstandard.c:
  120. X    Bessel functions fixed.  However, they only accept real arguments.
  121. Xterm.h:
  122. X    Moved most terminal defines from makefiles to new file term.h.
  123. X
  124. Xdocs/gnuplot.doc:
  125. X        Fixed a troff problem.
  126. X        Added note about bessel function limitations.
  127. X        Added cd and pwd commands.
  128. Xdocs/titlepage.ms:
  129. Xdocs/titlepage.tex:
  130. X        Updated version number to 2.0.
  131. X
  132. Xdocs/latextut/tutorial.tex:
  133. X    Mentioned a new package of useful auxiliary programs for latex users.
  134. X
  135. Xterm/eepic.trm:
  136. X        Ultrix cc initialiser problem fixed.
  137. Xterm/eps60.trm:
  138. X    New epson driver for 60dpi printers.
  139. Xterm/epson.trm:
  140. X    New Star color printer driver.
  141. Xterm/hpljet.trm:
  142. X    Fixed text placement.
  143. Xterm/hpgl.trm:
  144. X        Ultrix cc initialiser problem fixed.
  145. Xterm/imagen.trm:
  146. X        Ultrix cc initialiser problem fixed.
  147. Xterm/latex.trm: 
  148. X    Many bugs fixed: some to help out different compilers, some bugs
  149. X      in LATEX_linetype that had caused coredumps, and several
  150. X      details in the line-drawing routines. This last one had
  151. X      sometimes left gaps in lines that were near-vertical.
  152. X    New emTeX driver.
  153. X        Ultrix cc initialiser problem fixed.
  154. Xterm/pc.trm:
  155. X    Added Turbo C ATT6300 driver.
  156. Xterm/post.trm:
  157. X    Added "0 setgray" to epsf output.
  158. X        Ultrix cc initialiser problem fixed.
  159. X        Added stroke before show.
  160. Xterm/t410x.trm:
  161. X    New Tektronix 410x driver.
  162. Xterm/x11.trm:
  163. Xgnuplot_x11.c:
  164. X    New X11 driver.
  165. Xterm/unixpc.trm: 
  166. X    Use stdout and not stdin as the window device.
  167. X
  168. X
  169. XMail Addresses
  170. X--------------
  171. X
  172. XThe mailing list info-gnuplot exists as a forum for discussions about 
  173. Xgnuplot.  About the only gnuplot topic not supported by this list is 
  174. Xbug reports.  They are handled by a different mail alias, bug-gnuplot.  
  175. X
  176. XTo be removed or add someone to the mailing list send mail to:
  177. X
  178. Xpixar!info-gnuplot-request@sun.com
  179. X
  180. X
  181. XTo report bugs send mail to:
  182. X
  183. Xpixar!bug-gnuplot@sun.com
  184. X
  185. X
  186. XTo ask a question or discuss gnuplot send mail to:
  187. X
  188. Xpixar!info-gnuplot@sun.com
  189. X
  190. X
  191. Xpixar is a UUCP site.  sun.com is a UUCP and Internet site.  
  192. XIn the above addresses, sun.com can be replaced by ucbvax.berkeley.edu.
  193. X
  194. X
  195. XEnd of README.patch1
  196. END_OF_README.patch1
  197. if test 4083 -ne `wc -c <README.patch1`; then
  198.     echo shar: \"README.patch1\" unpacked with wrong size!
  199. fi
  200. # end of overwriting check
  201. fi
  202. if test -f version.c -a "${1}" != "-c" ; then 
  203.   echo shar: Will not over-write existing file \"version.c\"
  204. else
  205. echo shar: Extracting \"version.c\" \(220 characters\)
  206. sed "s/^X//" >version.c <<'END_OF_version.c'
  207. Xchar version[] = "2.0";
  208. Xchar patchlevel[] = "1";
  209. Xchar date[] = "Tue Sep 18 14:46:32 EST 1990";
  210. X
  211. X/* override in Makefile */
  212. X#ifndef CONTACT
  213. X# define CONTACT "pixar!bug-gnuplot@sun.com";
  214. X#endif
  215. Xchar bug_email[] = CONTACT;
  216. END_OF_version.c
  217. if test 220 -ne `wc -c <version.c`; then
  218.     echo shar: \"version.c\" unpacked with wrong size!
  219. fi
  220. # end of overwriting check
  221. fi
  222. if test -f setshow.c -a "${1}" != "-c" ; then 
  223.   echo shar: Will not over-write existing file \"setshow.c\"
  224. else
  225. echo shar: Extracting \"setshow.c\" \(41480 characters\)
  226. sed "s/^X//" >setshow.c <<'END_OF_setshow.c'
  227. X/* GNUPLOT - setshow.c */
  228. X/*
  229. X * Copyright (C) 1986, 1987, 1990   Thomas Williams, Colin Kelley
  230. X *
  231. X * Permission to use, copy, and distribute this software and its
  232. X * documentation for any purpose with or without fee is hereby granted, 
  233. X * provided that the above copyright notice appear in all copies and 
  234. X * that both that copyright notice and this permission notice appear 
  235. X * in supporting documentation.
  236. X *
  237. X * Permission to modify the software is granted, but not the right to
  238. X * distribute the modified code.  Modifications are to be distributed 
  239. X * as patches to released version.
  240. X *  
  241. X * This software  is provided "as is" without express or implied warranty.
  242. X * 
  243. X *
  244. X * AUTHORS
  245. X * 
  246. X *   Original Software:
  247. X *     Thomas Williams,  Colin Kelley.
  248. X * 
  249. X *   Gnuplot 2.0 additions:
  250. X *       Russell Lang, Dave Kotz, John Campbell.
  251. X * 
  252. X * send your comments or suggestions to (pixar!info-gnuplot@sun.com).
  253. X * 
  254. X */
  255. X
  256. X#include <stdio.h>
  257. X#include <math.h>
  258. X#include "plot.h"
  259. X#include "setshow.h"
  260. X
  261. X#define DEF_FORMAT   "%g"    /* default format for tic mark labels */
  262. X#define SIGNIF (0.01)        /* less than one hundredth of a tic mark */
  263. X
  264. X/*
  265. X * global variables to hold status of 'set' options
  266. X *
  267. X */
  268. XBOOLEAN            autoscale_x    = TRUE;
  269. XBOOLEAN            autoscale_y    = TRUE;
  270. XBOOLEAN            autoscale_lx    = TRUE;
  271. XBOOLEAN            autoscale_ly    = TRUE;
  272. XBOOLEAN                clip_points    = FALSE;
  273. XBOOLEAN                clip_lines1    = TRUE;
  274. XBOOLEAN                clip_lines2    = FALSE;
  275. Xchar            dummy_var[MAX_ID_LEN+1] = "x";
  276. Xchar            xformat[MAX_ID_LEN+1] = DEF_FORMAT;
  277. Xchar            yformat[MAX_ID_LEN+1] = DEF_FORMAT;
  278. Xenum PLOT_STYLE data_style    = POINTS,
  279. X                func_style    = LINES;
  280. XBOOLEAN            grid        = FALSE;
  281. Xint                key            = -1;    /* default position */
  282. Xdouble            key_x, key_y;        /* user specified position for key */
  283. XBOOLEAN            log_x        = FALSE,
  284. X                log_y        = FALSE;
  285. XFILE*            outfile;
  286. Xchar            outstr[MAX_ID_LEN+1] = "STDOUT";
  287. XBOOLEAN            polar        = FALSE;
  288. Xint                samples        = SAMPLES;
  289. Xfloat            xsize        = 1.0;  /* scale factor for size */
  290. Xfloat            ysize        = 1.0;  /* scale factor for size */
  291. Xint                term        = 0;                /* unknown term is 0 */
  292. Xchar            title[MAX_LINE_LEN+1] = "";
  293. Xchar            xlabel[MAX_LINE_LEN+1] = "";
  294. Xchar            ylabel[MAX_LINE_LEN+1] = "";
  295. Xdouble            xmin        = -10.0,
  296. X                xmax        = 10.0,
  297. X                ymin        = -10.0,
  298. X                ymax        = 10.0;
  299. Xdouble            loff        = 0.0,
  300. X                roff        = 0.0,
  301. X                toff        = 0.0,
  302. X                boff        = 0.0;
  303. Xdouble            zero = ZERO;            /* zero threshold, not 0! */
  304. X
  305. XBOOLEAN xtics = TRUE;
  306. XBOOLEAN ytics = TRUE;
  307. X
  308. Xstruct ticdef xticdef = {TIC_COMPUTED};
  309. Xstruct ticdef yticdef = {TIC_COMPUTED};
  310. X
  311. XBOOLEAN            tic_in        = TRUE;
  312. X
  313. Xstruct text_label *first_label = NULL;
  314. Xstruct arrow_def *first_arrow = NULL;
  315. X
  316. X/*** other things we need *****/
  317. Xextern char *strcpy(),*strcat();
  318. Xextern int strlen();
  319. X
  320. X/* input data, parsing variables */
  321. Xextern struct lexical_unit token[];
  322. Xextern char input_line[];
  323. Xextern int num_tokens, c_token;
  324. X
  325. Xextern char replot_line[];
  326. Xextern struct udvt_entry *first_udv;
  327. X
  328. Xextern double magnitude(),real();
  329. Xextern struct value *const_express();
  330. X
  331. X/******** Local functions ********/
  332. Xstatic void set_label();
  333. Xstatic void set_nolabel();
  334. Xstatic void set_arrow();
  335. Xstatic void set_noarrow();
  336. Xstatic void load_tics();
  337. Xstatic void load_tic_user();
  338. Xstatic void free_marklist();
  339. Xstatic void load_tic_series();
  340. Xstatic void load_offsets();
  341. X
  342. Xstatic void show_style(), show_range(), show_zero();
  343. Xstatic void show_offsets(), show_output(), show_samples(), show_size();
  344. Xstatic void show_title(), show_xlabel(), show_ylabel();
  345. Xstatic void show_label(), show_arrow(), show_grid(), show_key();
  346. Xstatic void show_polar(), show_tics(), show_ticdef();
  347. Xstatic void show_term(), show_plot(), show_autoscale(), show_clip();
  348. Xstatic void show_format(), show_logscale(), show_variables();
  349. X
  350. Xstatic void delete_label();
  351. Xstatic int assign_label_tag();
  352. Xstatic void delete_arrow();
  353. Xstatic int assign_arrow_tag();
  354. X
  355. X/******** The 'set' command ********/
  356. Xvoid
  357. Xset_command()
  358. X{
  359. X     static char testfile[MAX_LINE_LEN+1];
  360. X
  361. X    c_token++;
  362. X
  363. X    if (almost_equals(c_token,"ar$row")) {
  364. X        c_token++;
  365. X        set_arrow();
  366. X    }
  367. X    else if (almost_equals(c_token,"noar$row")) {
  368. X        c_token++;
  369. X        set_noarrow();
  370. X    }
  371. X     else if (almost_equals(c_token,"au$toscale")) {
  372. X        c_token++;
  373. X        if (END_OF_COMMAND) {
  374. X           autoscale_x = autoscale_y = TRUE;
  375. X        } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
  376. X           autoscale_x = autoscale_y = TRUE;
  377. X           c_token++;
  378. X        } else if (equals(c_token, "x")) {
  379. X           autoscale_x = TRUE;
  380. X           c_token++;
  381. X        } else if (equals(c_token, "y")) {
  382. X           autoscale_y = TRUE;
  383. X           c_token++;
  384. X        }
  385. X    } 
  386. X    else if (almost_equals(c_token,"noau$toscale")) {
  387. X        c_token++;
  388. X        if (END_OF_COMMAND) {
  389. X           autoscale_x = autoscale_y = FALSE;
  390. X        } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
  391. X           autoscale_x = autoscale_y = FALSE;
  392. X           c_token++;
  393. X        } else if (equals(c_token, "x")) {
  394. X           autoscale_x = FALSE;
  395. X           c_token++;
  396. X        } else if (equals(c_token, "y")) {
  397. X           autoscale_y = FALSE;
  398. X           c_token++;
  399. X        }
  400. X    } 
  401. X    else if (almost_equals(c_token,"c$lip")) {
  402. X        c_token++;
  403. X        if (END_OF_COMMAND)
  404. X         /* assuming same as points */
  405. X         clip_points = TRUE;
  406. X        else if (almost_equals(c_token, "p$oints"))
  407. X         clip_points = TRUE;
  408. X        else if (almost_equals(c_token, "o$ne"))
  409. X         clip_lines1 = TRUE;
  410. X        else if (almost_equals(c_token, "t$wo"))
  411. X         clip_lines2 = TRUE;
  412. X        else
  413. X         int_error("expecting 'points', 'one', or 'two'", c_token);
  414. X        c_token++;
  415. X    }
  416. X    else if (almost_equals(c_token,"noc$lip")) {
  417. X        c_token++;
  418. X        if (END_OF_COMMAND) {
  419. X           /* same as all three */
  420. X           clip_points = FALSE;
  421. X           clip_lines1 = FALSE;
  422. X           clip_lines2 = FALSE;
  423. X        } else if (almost_equals(c_token, "p$oints"))
  424. X         clip_points = FALSE;
  425. X        else if (almost_equals(c_token, "o$ne"))
  426. X         clip_lines1 = FALSE;
  427. X        else if (almost_equals(c_token, "t$wo"))
  428. X         clip_lines2 = FALSE;
  429. X        else
  430. X         int_error("expecting 'points', 'one', or 'two'", c_token);
  431. X        c_token++;
  432. X    }
  433. X    else if (almost_equals(c_token,"d$ata")) {
  434. X        c_token++;
  435. X        if (!almost_equals(c_token,"s$tyle"))
  436. X            int_error("expecting keyword 'style'",c_token);
  437. X        data_style = get_style();
  438. X    }
  439. X    else if (almost_equals(c_token,"d$ummy")) {
  440. X        c_token++;
  441. X        copy_str(dummy_var,c_token++);
  442. X    }
  443. X    else if (almost_equals(c_token,"fo$rmat")) {
  444. X        BOOLEAN setx, sety;
  445. X        c_token++;
  446. X        if (equals(c_token,"x")) {
  447. X            setx = TRUE; sety = FALSE;
  448. X            c_token++;
  449. X        }
  450. X        else if (equals(c_token,"y")) {
  451. X            setx = FALSE; sety = TRUE;
  452. X            c_token++;
  453. X        }
  454. X        else if (equals(c_token,"xy") || equals(c_token,"yx")) {
  455. X            setx = sety = TRUE;
  456. X            c_token++;
  457. X        }
  458. X        else if (isstring(c_token) || END_OF_COMMAND) {
  459. X            /* Assume he wants both */
  460. X            setx = sety = TRUE;
  461. X        }
  462. X        if (END_OF_COMMAND) {
  463. X            if (setx)
  464. X                (void) strcpy(xformat,DEF_FORMAT);
  465. X            if (sety)
  466. X                (void) strcpy(yformat,DEF_FORMAT);
  467. X        }
  468. X        else {
  469. X            if (!isstring(c_token))
  470. X              int_error("expecting format string",c_token);
  471. X            else {
  472. X                if (setx)
  473. X                 quote_str(xformat,c_token);
  474. X                if (sety)
  475. X                 quote_str(yformat,c_token);
  476. X                c_token++;
  477. X            }
  478. X        }
  479. X    }
  480. X    else if (almost_equals(c_token,"fu$nction")) {
  481. X        c_token++;
  482. X        if (!almost_equals(c_token,"s$tyle"))
  483. X            int_error("expecting keyword 'style'",c_token);
  484. X        func_style = get_style();
  485. X    }
  486. X    else if (almost_equals(c_token,"la$bel")) {
  487. X        c_token++;
  488. X        set_label();
  489. X    }
  490. X    else if (almost_equals(c_token,"nola$bel")) {
  491. X        c_token++;
  492. X        set_nolabel();
  493. X    }
  494. X    else if (almost_equals(c_token,"lo$gscale")) {
  495. X        c_token++;
  496. X        if (END_OF_COMMAND) {
  497. X           log_x = log_y = TRUE;
  498. X        } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
  499. X           log_x = log_y = TRUE;
  500. X           c_token++;
  501. X        } else if (equals(c_token, "x")) {
  502. X           log_x = TRUE;
  503. X           c_token++;
  504. X        } else if (equals(c_token, "y")) {
  505. X           log_y = TRUE;
  506. X           c_token++;
  507. X        }
  508. X    }
  509. X    else if (almost_equals(c_token,"nolo$gscale")) {
  510. X        c_token++;
  511. X        if (END_OF_COMMAND) {
  512. X           log_x = log_y = FALSE;
  513. X        } else if (equals(c_token, "xy") || equals(c_token, "yx")) {
  514. X           log_x = log_y = FALSE;
  515. X           c_token++;
  516. X        } else if (equals(c_token, "x")) {
  517. X           log_x = FALSE;
  518. X           c_token++;
  519. X        } else if (equals(c_token, "y")) {
  520. X           log_y = FALSE;
  521. X           c_token++;
  522. X        }
  523. X    } 
  524. X    else if (almost_equals(c_token,"of$fsets")) {
  525. X        c_token++;
  526. X        if (END_OF_COMMAND) {
  527. X            loff = roff = toff = boff = 0.0;  /* Reset offsets */
  528. X        }
  529. X        else {
  530. X            load_offsets (&loff,&roff,&toff,&boff);
  531. X        }
  532. X    }
  533. X    else if (almost_equals(c_token,"o$utput")) {
  534. X        register FILE *f;
  535. X
  536. X        c_token++;
  537. X        if (term && term_init)
  538. X            (*term_tbl[term].reset)();
  539. X        if (END_OF_COMMAND) {    /* no file specified */
  540. X             UP_redirect (4);
  541. X            if (outfile != stdout) /* Never close stdout */
  542. X                (void) fclose(outfile);
  543. X            outfile = stdout; /* Don't dup... */
  544. X            term_init = FALSE;
  545. X            (void) strcpy(outstr,"STDOUT");
  546. X        } else if (!isstring(c_token))
  547. X            int_error("expecting filename",c_token);
  548. X        else {
  549. X            quote_str(testfile,c_token);
  550. X            if ((f = fopen(testfile,"w")) == (FILE *)NULL) {
  551. X              os_error("cannot open file; output not changed",c_token);
  552. X            }
  553. X            if (outfile != stdout) /* Never close stdout */
  554. X                (void) fclose(outfile);
  555. X            outfile = f;
  556. X            term_init = FALSE;
  557. X            outstr[0] = '\'';
  558. X            (void) strcat(strcpy(outstr+1,testfile),"'");
  559. X             UP_redirect (1);
  560. X        }
  561. X        c_token++;
  562. X    }
  563. X    else if (almost_equals(c_token,"tit$le")) {
  564. X        c_token++;
  565. X        if (END_OF_COMMAND) {    /* no label specified */
  566. X            title[0] = '\0';
  567. X        } else {
  568. X        quotel_str(title,c_token);
  569. X        c_token++;
  570. X        }
  571. X    } 
  572. X    else if (almost_equals(c_token,"xl$abel")) {
  573. X        c_token++;
  574. X        if (END_OF_COMMAND) {    /* no label specified */
  575. X            xlabel[0] = '\0';
  576. X        } else {
  577. X        quotel_str(xlabel,c_token);
  578. X        c_token++;
  579. X        }
  580. X    } 
  581. X    else if (almost_equals(c_token,"yl$abel")) {
  582. X        c_token++;
  583. X        if (END_OF_COMMAND) {    /* no label specified */
  584. X            ylabel[0] = '\0';
  585. X        } else {
  586. X        quotel_str(ylabel,c_token);
  587. X        c_token++;
  588. X        }
  589. X    } 
  590. X    else if (almost_equals(c_token,"pol$ar")) {
  591. X        if (!polar) {
  592. X           polar = TRUE;
  593. X           xmin = 0.0;
  594. X           xmax = 2*Pi;
  595. X        }
  596. X        c_token++;
  597. X    }
  598. X    else if (almost_equals(c_token,"nopo$lar")) {
  599. X        if (polar) {
  600. X           polar = FALSE;
  601. X           xmin = -10.0;
  602. X           xmax = 10.0;
  603. X        }
  604. X        c_token++;
  605. X    }
  606. X    else if (almost_equals(c_token,"g$rid")) {
  607. X        grid = TRUE;
  608. X        c_token++;
  609. X    }
  610. X    else if (almost_equals(c_token,"nog$rid")) {
  611. X        grid = FALSE;
  612. X        c_token++;
  613. X    }
  614. X    else if (almost_equals(c_token,"k$ey")) {
  615. X        struct value a;
  616. X        c_token++;
  617. X        if (END_OF_COMMAND) {
  618. X            key = -1;
  619. X        } 
  620. X        else {
  621. X            key_x = real(const_express(&a));
  622. X            if (!equals(c_token,","))
  623. X                int_error("',' expected",c_token);
  624. X            c_token++;
  625. X            key_y = real(const_express(&a));
  626. X            key = 1;
  627. X        } 
  628. X    }
  629. X    else if (almost_equals(c_token,"nok$ey")) {
  630. X        key = 0;
  631. X        c_token++;
  632. X    }
  633. X    else if (almost_equals(c_token,"tic$s")) {
  634. X        tic_in = TRUE;
  635. X        c_token++;
  636. X        if (almost_equals(c_token,"i$n")) {
  637. X            tic_in = TRUE;
  638. X            c_token++;
  639. X        }
  640. X        else if (almost_equals(c_token,"o$ut")) {
  641. X            tic_in = FALSE;
  642. X            c_token++;
  643. X        }
  644. X    }
  645. X     else if (almost_equals(c_token,"xt$ics")) {
  646. X        xtics = TRUE;
  647. X        c_token++;
  648. X        if (END_OF_COMMAND) { /* reset to default */
  649. X           if (xticdef.type == TIC_USER) {
  650. X              free_marklist(xticdef.def.user);
  651. X              xticdef.def.user = NULL;
  652. X           }
  653. X           xticdef.type = TIC_COMPUTED;
  654. X        }
  655. X        else
  656. X         load_tics(&xticdef);
  657. X    } 
  658. X     else if (almost_equals(c_token,"noxt$ics")) {
  659. X        xtics = FALSE;
  660. X        c_token++;
  661. X    } 
  662. X     else if (almost_equals(c_token,"yt$ics")) {
  663. X        ytics = TRUE;
  664. X        c_token++;
  665. X        if (END_OF_COMMAND) { /* reset to default */
  666. X           if (yticdef.type == TIC_USER) {
  667. X              free_marklist(yticdef.def.user);
  668. X              yticdef.def.user = NULL;
  669. X           }
  670. X           yticdef.type = TIC_COMPUTED;
  671. X        }
  672. X        else
  673. X         load_tics(&yticdef);
  674. X    } 
  675. X     else if (almost_equals(c_token,"noyt$ics")) {
  676. X        ytics = FALSE;
  677. X        c_token++;
  678. X    } 
  679. X    else if (almost_equals(c_token,"sa$mples")) {
  680. X        register int tsamp;
  681. X        struct value a;
  682. X
  683. X        c_token++;
  684. X        tsamp = (int)magnitude(const_express(&a));
  685. X        if (tsamp < 1)
  686. X            int_error("sampling rate must be > 0; sampling unchanged",
  687. X                c_token);
  688. X        else {
  689. X             extern struct curve_points *first_plot;
  690. X            register struct curve_points *f_p = first_plot;
  691. X
  692. X            first_plot = NULL;
  693. X            cp_free(f_p);
  694. X            samples = tsamp;
  695. X        }
  696. X    }
  697. X    else if (almost_equals(c_token,"si$ze")) {
  698. X        struct value s;
  699. X        c_token++;
  700. X        if (END_OF_COMMAND) {
  701. X            xsize = 1.0;
  702. X            ysize = 1.0;
  703. X        } 
  704. X        else {
  705. X                xsize=real(const_express(&s));
  706. X                if (!equals(c_token,","))
  707. X                    int_error("',' expected",c_token);
  708. X                c_token++;
  709. X                ysize=real(const_express(&s));
  710. X        } 
  711. X    } 
  712. X    else if (almost_equals(c_token,"t$erminal")) {
  713. X        c_token++;
  714. X        if (END_OF_COMMAND) {
  715. X            list_terms();
  716. X            screen_ok = FALSE;
  717. X        }
  718. X        else {
  719. X            if (term && term_init) {
  720. X                (*term_tbl[term].reset)();
  721. X                (void) fflush(outfile);
  722. X            }
  723. X            term = set_term(c_token);
  724. X            c_token++;
  725. X        }
  726. X    }
  727. X    else if (almost_equals(c_token,"xr$ange")) {
  728. X         BOOLEAN changed;
  729. X        c_token++;
  730. X        if (!equals(c_token,"["))
  731. X            int_error("expecting '['",c_token);
  732. X        c_token++;
  733. X        changed = load_range(&xmin,&xmax);
  734. X        if (!equals(c_token,"]"))
  735. X          int_error("expecting ']'",c_token);
  736. X        c_token++;
  737. X        if (changed)
  738. X          autoscale_x = FALSE;
  739. X    }
  740. X    else if (almost_equals(c_token,"yr$ange")) {
  741. X         BOOLEAN changed;
  742. X        c_token++;
  743. X        if (!equals(c_token,"["))
  744. X            int_error("expecting '['",c_token);
  745. X        c_token++;
  746. X        changed = load_range(&ymin,&ymax);
  747. X        if (!equals(c_token,"]"))
  748. X          int_error("expecting ']'",c_token);
  749. X        c_token++;
  750. X        if (changed)
  751. X          autoscale_y = FALSE;
  752. X    }
  753. X    else if (almost_equals(c_token,"z$ero")) {
  754. X        struct value a;
  755. X        c_token++;
  756. X        zero = magnitude(const_express(&a));
  757. X    }
  758. X    else
  759. X        int_error(
  760. X    "valid set options:  '{no}arrow', {no}autoscale', '{no}clip', data', \n\
  761. X    'dummy', 'format', 'function', '{no}grid', '{no}key', '{no}label', \n\
  762. X    '{no}logscale','offsets', 'output', '{no}polar', 'samples', \n\
  763. X    'size', 'terminal', 'tics', 'title', 'xlabel', 'xrange', 'xtics', \n\
  764. X    'ylabel', 'yrange', 'ytics', 'zero',\n",
  765. X    c_token);
  766. X}
  767. X
  768. X/*********** Support functions for set_command ***********/
  769. X
  770. X/* process a 'set label' command */
  771. X/* set label {tag} {label_text} {at x,y} {pos} */
  772. Xstatic void
  773. Xset_label()
  774. X{
  775. X    struct value a;
  776. X    struct text_label *this_label = NULL;
  777. X    struct text_label *new_label = NULL;
  778. X    struct text_label *prev_label = NULL;
  779. X    double x, y;
  780. X    char text[MAX_LINE_LEN+1];
  781. X    enum JUSTIFY just;
  782. X    int tag;
  783. X    BOOLEAN set_text, set_position, set_just;
  784. X
  785. X    /* get tag */
  786. X    if (!END_OF_COMMAND 
  787. X       && !isstring(c_token) 
  788. X       && !equals(c_token, "at")
  789. X       && !equals(c_token, "left")
  790. X       && !equals(c_token, "center")
  791. X       && !equals(c_token, "centre")
  792. X       && !equals(c_token, "right")) {
  793. X       /* must be a tag expression! */
  794. X       tag = (int)real(const_express(&a));
  795. X       if (tag <= 0)
  796. X        int_error("tag must be > zero", c_token);
  797. X    } else
  798. X     tag = assign_label_tag(); /* default next tag */
  799. X     
  800. X    /* get text */
  801. X    if (!END_OF_COMMAND && isstring(c_token)) {
  802. X       /* get text */
  803. X       quotel_str(text, c_token);
  804. X       c_token++;
  805. X       set_text = TRUE;
  806. X    } else {
  807. X       text[0] = '\0';        /* default no text */
  808. X       set_text = FALSE;
  809. X    }
  810. X     
  811. X    /* get justification - what the heck, let him put it here */
  812. X    if (!END_OF_COMMAND && !equals(c_token, "at")) {
  813. X       if (almost_equals(c_token,"l$eft")) {
  814. X          just = LEFT;
  815. X       }
  816. X       else if (almost_equals(c_token,"c$entre")
  817. X              || almost_equals(c_token,"c$enter")) {
  818. X          just = CENTRE;
  819. X       }
  820. X       else if (almost_equals(c_token,"r$ight")) {
  821. X          just = RIGHT;
  822. X       }
  823. X       else
  824. X        int_error("bad syntax in set label", c_token);
  825. X       c_token++;
  826. X       set_just = TRUE;
  827. X    } else {
  828. X       just = LEFT;            /* default left justified */
  829. X       set_just = FALSE;
  830. X    } 
  831. X
  832. X    /* get position */
  833. X    if (!END_OF_COMMAND && equals(c_token, "at")) {
  834. X       c_token++;
  835. X       if (END_OF_COMMAND)
  836. X        int_error("coordinates expected", c_token);
  837. X       /* get coordinates */
  838. X       x = real(const_express(&a));
  839. X       if (!equals(c_token,","))
  840. X        int_error("',' expected",c_token);
  841. X       c_token++;
  842. X       y = real(const_express(&a));
  843. X       set_position = TRUE;
  844. X    } else {
  845. X       x = y = 0;            /* default at origin */
  846. X       set_position = FALSE;
  847. X    }
  848. X
  849. X    /* get justification */
  850. X    if (!END_OF_COMMAND) {
  851. X       if (set_just)
  852. X        int_error("only one justification is allowed", c_token);
  853. X       if (almost_equals(c_token,"l$eft")) {
  854. X          just = LEFT;
  855. X       }
  856. X       else if (almost_equals(c_token,"c$entre")
  857. X              || almost_equals(c_token,"c$enter")) {
  858. X          just = CENTRE;
  859. X       }
  860. X       else if (almost_equals(c_token,"r$ight")) {
  861. X          just = RIGHT;
  862. X       }
  863. X       else
  864. X        int_error("bad syntax in set label", c_token);
  865. X       c_token++;
  866. X       set_just = TRUE;
  867. X    } 
  868. X
  869. X    if (!END_OF_COMMAND)
  870. X     int_error("extraneous or out-of-order arguments in set label", c_token);
  871. X
  872. X    /* OK! add label */
  873. X    if (first_label != NULL) { /* skip to last label */
  874. X       for (this_label = first_label; this_label != NULL ; 
  875. X           prev_label = this_label, this_label = this_label->next)
  876. X        /* is this the label we want? */
  877. X        if (tag <= this_label->tag)
  878. X          break;
  879. X    }
  880. X    if (this_label != NULL && tag == this_label->tag) {
  881. X       /* changing the label */
  882. X       if (set_position) {
  883. X          this_label->x = x;
  884. X          this_label->y = y;
  885. X       }
  886. X       if (set_text)
  887. X        (void) strcpy(this_label->text, text);
  888. X       if (set_just)
  889. X        this_label->pos = just;
  890. X    } else {
  891. X       /* adding the label */
  892. X       new_label = (struct text_label *) 
  893. X        alloc ( (unsigned int) sizeof(struct text_label), "label");
  894. X       if (prev_label != NULL)
  895. X        prev_label->next = new_label; /* add it to end of list */
  896. X       else 
  897. X        first_label = new_label; /* make it start of list */
  898. X       new_label->tag = tag;
  899. X       new_label->next = this_label;
  900. X       new_label->x = x;
  901. X       new_label->y = y;
  902. X       (void) strcpy(new_label->text, text);
  903. X       new_label->pos = just;
  904. X    }
  905. X}
  906. X
  907. X/* process 'set nolabel' command */
  908. X/* set nolabel {tag} */
  909. Xstatic void
  910. Xset_nolabel()
  911. X{
  912. X    struct value a;
  913. X    struct text_label *this_label;
  914. X    struct text_label *prev_label; 
  915. X    int tag;
  916. X
  917. X    if (END_OF_COMMAND) {
  918. X       /* delete all labels */
  919. X       while (first_label != NULL)
  920. X        delete_label((struct text_label *)NULL,first_label);
  921. X    }
  922. X    else {
  923. X       /* get tag */
  924. X       tag = (int)real(const_express(&a));
  925. X       if (!END_OF_COMMAND)
  926. X        int_error("extraneous arguments to set nolabel", c_token);
  927. X       for (this_label = first_label, prev_label = NULL;
  928. X           this_label != NULL;
  929. X           prev_label = this_label, this_label = this_label->next) {
  930. X          if (this_label->tag == tag) {
  931. X             delete_label(prev_label,this_label);
  932. X             return;        /* exit, our job is done */
  933. X          }
  934. X       }
  935. X       int_error("label not found", c_token);
  936. X    }
  937. X}
  938. X
  939. X/* assign a new label tag */
  940. X/* labels are kept sorted by tag number, so this is easy */
  941. Xstatic int                /* the lowest unassigned tag number */
  942. Xassign_label_tag()
  943. X{
  944. X    struct text_label *this_label;
  945. X    int last = 0;            /* previous tag value */
  946. X
  947. X    for (this_label = first_label; this_label != NULL;
  948. X        this_label = this_label->next)
  949. X     if (this_label->tag == last+1)
  950. X       last++;
  951. X     else
  952. X       break;
  953. X    
  954. X    return (last+1);
  955. X}
  956. X
  957. X/* delete label from linked list started by first_label.
  958. X * called with pointers to the previous label (prev) and the 
  959. X * label to delete (this).
  960. X * If there is no previous label (the label to delete is
  961. X * first_label) then call with prev = NULL.
  962. X */
  963. Xstatic void
  964. Xdelete_label(prev,this)
  965. X    struct text_label *prev, *this;
  966. X{
  967. X    if (this!=NULL)    {        /* there really is something to delete */
  968. X       if (prev!=NULL)        /* there is a previous label */
  969. X        prev->next = this->next; 
  970. X       else                /* this = first_label so change first_label */
  971. X        first_label = this->next;
  972. X       free((char *)this);
  973. X    }
  974. X}
  975. X
  976. X
  977. X/* process a 'set arrow' command */
  978. X/* set arrow {tag} {from x,y} {to x,y} */
  979. Xstatic void
  980. Xset_arrow()
  981. X{
  982. X    struct value a;
  983. X    struct arrow_def *this_arrow = NULL;
  984. X    struct arrow_def *new_arrow = NULL;
  985. X    struct arrow_def *prev_arrow = NULL;
  986. X    double sx, sy;
  987. X    double ex, ey;
  988. X    int tag;
  989. X    BOOLEAN set_start, set_end;
  990. X
  991. X    /* get tag */
  992. X    if (!END_OF_COMMAND 
  993. X       && !equals(c_token, "from")
  994. X       && !equals(c_token, "to")) {
  995. X       /* must be a tag expression! */
  996. X       tag = (int)real(const_express(&a));
  997. X       if (tag <= 0)
  998. X        int_error("tag must be > zero", c_token);
  999. X    } else
  1000. X     tag = assign_arrow_tag(); /* default next tag */
  1001. X     
  1002. X    /* get start position */
  1003. X    if (!END_OF_COMMAND && equals(c_token, "from")) {
  1004. X       c_token++;
  1005. X       if (END_OF_COMMAND)
  1006. X        int_error("start coordinates expected", c_token);
  1007. X       /* get coordinates */
  1008. X       sx = real(const_express(&a));
  1009. X       if (!equals(c_token,","))
  1010. X        int_error("',' expected",c_token);
  1011. X       c_token++;
  1012. X       sy = real(const_express(&a));
  1013. X       set_start = TRUE;
  1014. X    } else {
  1015. X       sx = sy = 0;            /* default at origin */
  1016. X       set_start = FALSE;
  1017. X    }
  1018. X
  1019. X    /* get end position */
  1020. X    if (!END_OF_COMMAND && equals(c_token, "to")) {
  1021. X       c_token++;
  1022. X       if (END_OF_COMMAND)
  1023. X        int_error("end coordinates expected", c_token);
  1024. X       /* get coordinates */
  1025. X       ex = real(const_express(&a));
  1026. X       if (!equals(c_token,","))
  1027. X        int_error("',' expected",c_token);
  1028. X       c_token++;
  1029. X       ey = real(const_express(&a));
  1030. X       set_end = TRUE;
  1031. X    } else {
  1032. X       ex = ey = 0;            /* default at origin */
  1033. X       set_end = FALSE;
  1034. X    }
  1035. X
  1036. X    /* get start position - what the heck, either order is ok */
  1037. X    if (!END_OF_COMMAND && equals(c_token, "from")) {
  1038. X       if (set_start)
  1039. X        int_error("only one 'from' is allowed", c_token);
  1040. X       c_token++;
  1041. X       if (END_OF_COMMAND)
  1042. X        int_error("start coordinates expected", c_token);
  1043. X       /* get coordinates */
  1044. X       sx = real(const_express(&a));
  1045. X       if (!equals(c_token,","))
  1046. X        int_error("',' expected",c_token);
  1047. X       c_token++;
  1048. X       sy = real(const_express(&a));
  1049. X       set_start = TRUE;
  1050. X    }
  1051. X
  1052. X    if (!END_OF_COMMAND)
  1053. X     int_error("extraneous or out-of-order arguments in set arrow", c_token);
  1054. X
  1055. X    /* OK! add arrow */
  1056. X    if (first_arrow != NULL) { /* skip to last arrow */
  1057. X       for (this_arrow = first_arrow; this_arrow != NULL ; 
  1058. X           prev_arrow = this_arrow, this_arrow = this_arrow->next)
  1059. X        /* is this the arrow we want? */
  1060. X        if (tag <= this_arrow->tag)
  1061. X          break;
  1062. X    }
  1063. X    if (this_arrow != NULL && tag == this_arrow->tag) {
  1064. X       /* changing the arrow */
  1065. X       if (set_start) {
  1066. X          this_arrow->sx = sx;
  1067. X          this_arrow->sy = sy;
  1068. X       }
  1069. X       if (set_end) {
  1070. X          this_arrow->ex = ex;
  1071. X          this_arrow->ey = ey;
  1072. X       }
  1073. X    } else {
  1074. X       /* adding the arrow */
  1075. X       new_arrow = (struct arrow_def *) 
  1076. X        alloc ( (unsigned int) sizeof(struct arrow_def), "arrow");
  1077. X       if (prev_arrow != NULL)
  1078. X        prev_arrow->next = new_arrow; /* add it to end of list */
  1079. X       else 
  1080. X        first_arrow = new_arrow; /* make it start of list */
  1081. X       new_arrow->tag = tag;
  1082. X       new_arrow->next = this_arrow;
  1083. X       new_arrow->sx = sx;
  1084. X       new_arrow->sy = sy;
  1085. X       new_arrow->ex = ex;
  1086. X       new_arrow->ey = ey;
  1087. X    }
  1088. X}
  1089. X
  1090. X/* process 'set noarrow' command */
  1091. X/* set noarrow {tag} */
  1092. Xstatic void
  1093. Xset_noarrow()
  1094. X{
  1095. X    struct value a;
  1096. X    struct arrow_def *this_arrow;
  1097. X    struct arrow_def *prev_arrow; 
  1098. X    int tag;
  1099. X
  1100. X    if (END_OF_COMMAND) {
  1101. X       /* delete all arrows */
  1102. X       while (first_arrow != NULL)
  1103. X        delete_arrow((struct arrow_def *)NULL,first_arrow);
  1104. X    }
  1105. X    else {
  1106. X       /* get tag */
  1107. X       tag = (int)real(const_express(&a));
  1108. X       if (!END_OF_COMMAND)
  1109. X        int_error("extraneous arguments to set noarrow", c_token);
  1110. X       for (this_arrow = first_arrow, prev_arrow = NULL;
  1111. X           this_arrow != NULL;
  1112. X           prev_arrow = this_arrow, this_arrow = this_arrow->next) {
  1113. X          if (this_arrow->tag == tag) {
  1114. X             delete_arrow(prev_arrow,this_arrow);
  1115. X             return;        /* exit, our job is done */
  1116. X          }
  1117. X       }
  1118. X       int_error("arrow not found", c_token);
  1119. X    }
  1120. X}
  1121. X
  1122. X/* assign a new arrow tag */
  1123. X/* arrows are kept sorted by tag number, so this is easy */
  1124. Xstatic int                /* the lowest unassigned tag number */
  1125. Xassign_arrow_tag()
  1126. X{
  1127. X    struct arrow_def *this_arrow;
  1128. X    int last = 0;            /* previous tag value */
  1129. X
  1130. X    for (this_arrow = first_arrow; this_arrow != NULL;
  1131. X        this_arrow = this_arrow->next)
  1132. X     if (this_arrow->tag == last+1)
  1133. X       last++;
  1134. X     else
  1135. X       break;
  1136. X
  1137. X    return (last+1);
  1138. X}
  1139. X
  1140. X/* delete arrow from linked list started by first_arrow.
  1141. X * called with pointers to the previous arrow (prev) and the 
  1142. X * arrow to delete (this).
  1143. X * If there is no previous arrow (the arrow to delete is
  1144. X * first_arrow) then call with prev = NULL.
  1145. X */
  1146. Xstatic void
  1147. Xdelete_arrow(prev,this)
  1148. X    struct arrow_def *prev, *this;
  1149. X{
  1150. X    if (this!=NULL)    {        /* there really is something to delete */
  1151. X       if (prev!=NULL)        /* there is a previous arrow */
  1152. X        prev->next = this->next; 
  1153. X       else                /* this = first_arrow so change first_arrow */
  1154. X        first_arrow = this->next;
  1155. X       free((char *)this);
  1156. X    }
  1157. X}
  1158. X
  1159. X
  1160. Xenum PLOT_STYLE            /* not static; used by command.c */
  1161. Xget_style()
  1162. X{
  1163. Xregister enum PLOT_STYLE ps;
  1164. X
  1165. X    c_token++;
  1166. X    if (almost_equals(c_token,"l$ines"))
  1167. X        ps = LINES;
  1168. X    else if (almost_equals(c_token,"i$mpulses"))
  1169. X        ps = IMPULSES;
  1170. X    else if (almost_equals(c_token,"p$oints"))
  1171. X        ps = POINTS;
  1172. X    else if (almost_equals(c_token,"linesp$oints"))
  1173. X        ps = LINESPOINTS;
  1174. X    else if (almost_equals(c_token,"d$ots"))
  1175. X        ps = DOTS;
  1176. X    else
  1177. X        int_error("expecting 'lines', 'points', 'linespoints', 'dots', or 'impulses'",c_token);
  1178. X    c_token++;
  1179. X    return(ps);
  1180. X}
  1181. X
  1182. X/* For set [xy]tics... command*/
  1183. Xstatic void
  1184. Xload_tics(tdef)
  1185. X    struct ticdef *tdef;    /* change this ticdef */
  1186. X{
  1187. X    if (equals(c_token,"(")) { /* set : TIC_USER */
  1188. X       c_token++;
  1189. X       load_tic_user(tdef);
  1190. X    } else {                /* series : TIC_SERIES */
  1191. X       load_tic_series(tdef);
  1192. X    }
  1193. X}
  1194. X
  1195. X/* load TIC_USER definition */
  1196. X/* (tic[,tic]...)
  1197. X * where tic is ["string"] value
  1198. X * Left paren is already scanned off before entry.
  1199. X */
  1200. Xstatic void
  1201. Xload_tic_user(tdef)
  1202. X    struct ticdef *tdef;
  1203. X{
  1204. X    struct ticmark *list = NULL; /* start of list */
  1205. X    struct ticmark *last = NULL; /* end of list */
  1206. X    struct ticmark *tic = NULL; /* new ticmark */
  1207. X    char temp_string[MAX_LINE_LEN];
  1208. X    struct value a;
  1209. X
  1210. X    while (!END_OF_COMMAND) {
  1211. X       /* parse a new ticmark */
  1212. X       tic = (struct ticmark *)alloc(sizeof(struct ticmark), (char *)NULL);
  1213. X       if (tic == (struct ticmark *)NULL) {
  1214. X          free_marklist(list);
  1215. X          int_error("out of memory for tic mark", c_token);
  1216. X       }
  1217. X
  1218. X       /* has a string with it? */
  1219. X       if (isstring(c_token)) {
  1220. X          quote_str(temp_string,c_token);
  1221. X          tic->label = alloc((unsigned int)strlen(temp_string)+1, "tic label");
  1222. X          (void) strcpy(tic->label, temp_string);
  1223. X          c_token++;
  1224. X       } else
  1225. X        tic->label = NULL;
  1226. X
  1227. X       /* in any case get the value */
  1228. X       tic->position = real(const_express(&a));
  1229. X       tic->next = NULL;
  1230. X
  1231. X       /* append to list */
  1232. X       if (list == NULL)
  1233. X        last = list = tic;    /* new list */
  1234. X       else {                /* append to list */
  1235. X          last->next = tic;
  1236. X          last = tic;
  1237. X       }
  1238. X
  1239. X       /* expect "," or ")" here */
  1240. X       if (!END_OF_COMMAND && equals(c_token, ","))
  1241. X        c_token++;        /* loop again */
  1242. X       else
  1243. X        break;            /* hopefully ")" */
  1244. X    }
  1245. X    
  1246. X    if (END_OF_COMMAND || !equals(c_token, ")")) {
  1247. X       free_marklist(list);
  1248. X       int_error("expecting right parenthesis )", c_token);
  1249. X    }
  1250. X    c_token++;
  1251. X    
  1252. X    /* successful list */
  1253. X    if (tdef->type == TIC_USER) {
  1254. X       /* remove old list */
  1255. X        /* VAX Optimiser was stuffing up following line. Turn Optimiser OFF */
  1256. X       free_marklist(tdef->def.user);
  1257. X       tdef->def.user = NULL;
  1258. X    }
  1259. X    tdef->type = TIC_USER;
  1260. X    tdef->def.user = list;
  1261. X}
  1262. X
  1263. Xstatic void
  1264. Xfree_marklist(list)
  1265. X    struct ticmark *list;
  1266. X{
  1267. X    register struct ticmark *freeable;
  1268. X
  1269. X    while (list != NULL) {
  1270. X       freeable = list;
  1271. X       list = list->next;
  1272. X       if (freeable->label != NULL)
  1273. X        free( (char *)freeable->label );
  1274. X       free( (char *)freeable );
  1275. X    }
  1276. X}
  1277. X
  1278. X/* load TIC_SERIES definition */
  1279. X/* start,incr[,end] */
  1280. Xstatic void
  1281. Xload_tic_series(tdef)
  1282. X    struct ticdef *tdef;
  1283. X{
  1284. X    double start, incr, end;
  1285. X    struct value a;
  1286. X    int incr_token;
  1287. X
  1288. X    start = real(const_express(&a));
  1289. X    if (!equals(c_token, ","))
  1290. X     int_error("expecting comma to separate start,incr", c_token);
  1291. X    c_token++;
  1292. X
  1293. X    incr_token = c_token;
  1294. X    incr = real(const_express(&a));
  1295. X
  1296. X    if (END_OF_COMMAND)
  1297. X     end = VERYLARGE;
  1298. X    else {
  1299. X       if (!equals(c_token, ","))
  1300. X        int_error("expecting comma to separate incr,end", c_token);
  1301. X       c_token++;
  1302. X
  1303. X       end = real(const_express(&a));
  1304. X    }
  1305. X    if (!END_OF_COMMAND)
  1306. X     int_error("tic series is defined by start,increment[,end]", 
  1307. X             c_token);
  1308. X    
  1309. X    if (start < end && incr <= 0)
  1310. X     int_error("increment must be positive", incr_token);
  1311. X    if (start > end && incr >= 0)
  1312. X     int_error("increment must be negative", incr_token);
  1313. X    if (start > end) {
  1314. X       /* put in order */
  1315. X        double numtics;
  1316. X        numtics = floor( (end*(1+SIGNIF) - start)/incr );
  1317. X        end = start;
  1318. X        start = end + numtics*incr;
  1319. X        incr = -incr;
  1320. X/*
  1321. X       double temp = start;
  1322. X       start = end;
  1323. X       end = temp;
  1324. X       incr = -incr;
  1325. X */
  1326. X    }
  1327. X
  1328. X    if (tdef->type == TIC_USER) {
  1329. X       /* remove old list */
  1330. X        /* VAX Optimiser was stuffing up following line. Turn Optimiser OFF */
  1331. X       free_marklist(tdef->def.user);
  1332. X       tdef->def.user = NULL;
  1333. X    }
  1334. X    tdef->type = TIC_SERIES;
  1335. X    tdef->def.series.start = start;
  1336. X    tdef->def.series.incr = incr;
  1337. X    tdef->def.series.end = end;
  1338. X}
  1339. X
  1340. Xstatic void
  1341. Xload_offsets (a, b, c, d)
  1342. Xdouble *a,*b, *c, *d;
  1343. X{
  1344. Xstruct value t;
  1345. X
  1346. X    *a = real (const_express(&t));  /* loff value */
  1347. X    c_token++;
  1348. X    if (equals(c_token,","))
  1349. X        c_token++;
  1350. X    if (END_OF_COMMAND) 
  1351. X        return;
  1352. X
  1353. X    *b = real (const_express(&t));  /* roff value */
  1354. X    c_token++;
  1355. X    if (equals(c_token,","))
  1356. X        c_token++;
  1357. X    if (END_OF_COMMAND) 
  1358. X        return;
  1359. X
  1360. X    *c = real (const_express(&t));  /* toff value */
  1361. X    c_token++;
  1362. X    if (equals(c_token,","))
  1363. X        c_token++;
  1364. X    if (END_OF_COMMAND) 
  1365. X        return;
  1366. X
  1367. X    *d = real (const_express(&t));  /* boff value */
  1368. X    c_token++;
  1369. X}
  1370. X
  1371. X
  1372. XBOOLEAN                    /* TRUE if a or b were changed */
  1373. Xload_range(a,b)            /* also used by command.c */
  1374. Xdouble *a,*b;
  1375. X{
  1376. Xstruct value t;
  1377. XBOOLEAN changed = FALSE;
  1378. X
  1379. X    if (equals(c_token,"]"))
  1380. X        return(FALSE);
  1381. X    if (END_OF_COMMAND) {
  1382. X        int_error("starting range value or ':' or 'to' expected",c_token);
  1383. X    } else if (!equals(c_token,"to") && !equals(c_token,":"))  {
  1384. X        *a = real(const_express(&t));
  1385. X        changed = TRUE;
  1386. X    }    
  1387. X    if (!equals(c_token,"to") && !equals(c_token,":"))
  1388. X        int_error("':' or keyword 'to' expected",c_token);
  1389. X    c_token++;
  1390. X    if (!equals(c_token,"]")) {
  1391. X        *b = real(const_express(&t));
  1392. X        changed = TRUE;
  1393. X     }
  1394. X     return(changed);
  1395. X}
  1396. X
  1397. X
  1398. X
  1399. X/******* The 'show' command *******/
  1400. Xvoid
  1401. Xshow_command()
  1402. X{
  1403. X    c_token++;
  1404. X
  1405. X    if (almost_equals(c_token,"ac$tion_table") ||
  1406. X             equals(c_token,"at") ) {
  1407. X        c_token++; 
  1408. X        show_at();
  1409. X        c_token++;
  1410. X    }
  1411. X    else if (almost_equals(c_token,"ar$row")) {
  1412. X        struct value a;
  1413. X        int tag = 0;
  1414. X
  1415. X        c_token++;
  1416. X        if (!END_OF_COMMAND) {
  1417. X           tag = (int)real(const_express(&a));
  1418. X           if (tag <= 0)
  1419. X            int_error("tag must be > zero", c_token);
  1420. X        }
  1421. X
  1422. X        (void) putc('\n',stderr);
  1423. X        show_arrow(tag);
  1424. X    }
  1425. X    else if (almost_equals(c_token,"au$toscale")) {
  1426. X        (void) putc('\n',stderr);
  1427. X        show_autoscale();
  1428. X        c_token++;
  1429. X    }
  1430. X    else if (almost_equals(c_token,"c$lip")) {
  1431. X        (void) putc('\n',stderr);
  1432. X        show_clip();
  1433. X        c_token++;
  1434. X    }
  1435. X    else if (almost_equals(c_token,"d$ata")) {
  1436. X        c_token++;
  1437. X        if (!almost_equals(c_token,"s$tyle"))
  1438. X            int_error("expecting keyword 'style'",c_token);
  1439. X        (void) putc('\n',stderr);
  1440. X        show_style("data",data_style);
  1441. X        c_token++;
  1442. X    }
  1443. X    else if (almost_equals(c_token,"d$ummy")) {
  1444. X        (void) fprintf(stderr,"\n\tdummy variable is %s\n",dummy_var);
  1445. X        c_token++;
  1446. X    }
  1447. X    else if (almost_equals(c_token,"fo$rmat")) {
  1448. X        show_format();
  1449. X        c_token++;
  1450. X    }
  1451. X    else if (almost_equals(c_token,"f$unctions")) {
  1452. X        c_token++;
  1453. X        if (almost_equals(c_token,"s$tyle"))  {
  1454. X            (void) putc('\n',stderr);
  1455. X            show_style("functions",func_style);
  1456. X            c_token++;
  1457. X        }
  1458. X        else
  1459. X            show_functions();
  1460. X    }
  1461. X    else if (almost_equals(c_token,"lo$gscale")) {
  1462. X        (void) putc('\n',stderr);
  1463. X        show_logscale();
  1464. X        c_token++;
  1465. X    }
  1466. X    else if (almost_equals(c_token,"of$fsets")) {
  1467. X        (void) putc('\n',stderr);
  1468. X        show_offsets();
  1469. X        c_token++;
  1470. X    }
  1471. X    else if (almost_equals(c_token,"o$utput")) {
  1472. X        (void) putc('\n',stderr);
  1473. X        show_output();
  1474. X        c_token++;
  1475. X    }
  1476. X    else if (almost_equals(c_token,"tit$le")) {
  1477. X        (void) putc('\n',stderr);
  1478. X        show_title();
  1479. X        c_token++;
  1480. X    }
  1481. X    else if (almost_equals(c_token,"xl$abel")) {
  1482. X        (void) putc('\n',stderr);
  1483. X        show_xlabel();
  1484. X        c_token++;
  1485. X    }
  1486. X    else if (almost_equals(c_token,"yl$abel")) {
  1487. X        (void) putc('\n',stderr);
  1488. X        show_ylabel();
  1489. X        c_token++;
  1490. X    }
  1491. X    else if (almost_equals(c_token,"la$bel")) {
  1492. X        struct value a;
  1493. X        int tag = 0;
  1494. X
  1495. X        c_token++;
  1496. X        if (!END_OF_COMMAND) {
  1497. X           tag = (int)real(const_express(&a));
  1498. X           if (tag <= 0)
  1499. X            int_error("tag must be > zero", c_token);
  1500. X        }
  1501. X
  1502. X        (void) putc('\n',stderr);
  1503. X        show_label(tag);
  1504. X    }
  1505. X    else if (almost_equals(c_token,"g$rid")) {
  1506. X        (void) putc('\n',stderr);
  1507. X        show_grid();
  1508. X        c_token++;
  1509. X    }
  1510. X    else if (almost_equals(c_token,"k$ey")) {
  1511. X        (void) putc('\n',stderr);
  1512. X        show_key();
  1513. X        c_token++;
  1514. X    }
  1515. X    else if (almost_equals(c_token,"p$lot")) {
  1516. X        (void) putc('\n',stderr);
  1517. X        show_plot();
  1518. X        c_token++;
  1519. X    }
  1520. X    else if (almost_equals(c_token,"pol$ar")) {
  1521. X        (void) putc('\n',stderr);
  1522. X        show_polar();
  1523. X        c_token++;
  1524. X    }
  1525. X    else if (almost_equals(c_token,"ti$cs")) {
  1526. X        (void) putc('\n',stderr);
  1527. X        show_tics(TRUE, TRUE);
  1528. X        c_token++;
  1529. X    }
  1530. X    else if (almost_equals(c_token,"xti$cs")) {
  1531. X        show_tics(TRUE, FALSE);
  1532. X        c_token++;
  1533. X    }
  1534. X    else if (almost_equals(c_token,"yti$cs")) {
  1535. X        show_tics(FALSE, TRUE);
  1536. X        c_token++;
  1537. X    }
  1538. X    else if (almost_equals(c_token,"sa$mples")) {
  1539. X        (void) putc('\n',stderr);
  1540. X        show_samples();
  1541. X        c_token++;
  1542. X    }
  1543. X    else if (almost_equals(c_token,"si$ze")) {
  1544. X        (void) putc('\n',stderr);
  1545. X        show_size();
  1546. X        c_token++;
  1547. X    }
  1548. X    else if (almost_equals(c_token,"t$erminal")) {
  1549. X        (void) putc('\n',stderr);
  1550. X        show_term();
  1551. X        c_token++;
  1552. X    }
  1553. X    else if (almost_equals(c_token,"v$ariables")) {
  1554. X        show_variables();
  1555. X        c_token++;
  1556. X    }
  1557. X    else if (almost_equals(c_token,"ve$rsion")) {
  1558. X        show_version();
  1559. X        c_token++;
  1560. X    }
  1561. X    else if (almost_equals(c_token,"xr$ange")) {
  1562. X        (void) putc('\n',stderr);
  1563. X        show_range('x',xmin,xmax);
  1564. X        c_token++;
  1565. X    }
  1566. X    else if (almost_equals(c_token,"yr$ange")) {
  1567. X        (void) putc('\n',stderr);
  1568. X        show_range('y',ymin,ymax);
  1569. X        c_token++;
  1570. X    }
  1571. X    else if (almost_equals(c_token,"z$ero")) {
  1572. X        (void) putc('\n',stderr);
  1573. X        show_zero();
  1574. X        c_token++;
  1575. X    }
  1576. X    else if (almost_equals(c_token,"a$ll")) {
  1577. X        c_token++;
  1578. X        show_version();
  1579. X        show_autoscale();
  1580. X        show_clip();
  1581. X        (void) fprintf(stderr,"\tdummy variable is %s\n",dummy_var);
  1582. X        show_format();
  1583. X        show_style("data",data_style);
  1584. X        show_style("functions",func_style);
  1585. X        show_grid();
  1586. X        show_label(0);
  1587. X        show_arrow(0);
  1588. X        show_key();
  1589. X        show_logscale();
  1590. X        show_offsets();
  1591. X        show_output();
  1592. X        show_polar();
  1593. X        show_samples();
  1594. X        show_size();
  1595. X        show_term();
  1596. X        show_tics(TRUE,TRUE);
  1597. X        show_range('x',xmin,xmax);
  1598. X        show_range('y',ymin,ymax);
  1599. X        show_title();
  1600. X        show_xlabel();
  1601. X        show_ylabel();
  1602. X        show_zero();
  1603. X        show_plot();
  1604. X        show_variables();
  1605. X        show_functions();
  1606. X        c_token++;
  1607. X    }
  1608. X    else
  1609. X        int_error(
  1610. X    "valid show options:  'action_table', 'all', 'arrow', 'autoscale',  \n\
  1611. X    'clip', 'data', 'dummy', 'format', 'function', 'grid', 'key', 'label', \n\
  1612. X    'logscale', 'offsets', 'output', 'plot', 'polar', 'samples', \n\
  1613. X    'size', 'terminal', 'tics', 'title', 'variables', 'version', \n\
  1614. X    'xlabel', 'xrange', 'xtics', 'ylabel', 'yrange', 'ytics', 'zero'", c_token);
  1615. X    screen_ok = FALSE;
  1616. X    (void) putc('\n',stderr);
  1617. X}
  1618. X
  1619. X
  1620. X/*********** support functions for 'show'  **********/
  1621. Xstatic void
  1622. Xshow_style(name,style)
  1623. Xchar name[];
  1624. Xenum PLOT_STYLE style;
  1625. X{
  1626. X    fprintf(stderr,"\t%s are plotted with ",name);
  1627. X    switch (style) {
  1628. X        case LINES: fprintf(stderr,"lines\n"); break;
  1629. X        case POINTS: fprintf(stderr,"points\n"); break;
  1630. X        case IMPULSES: fprintf(stderr,"impulses\n"); break;
  1631. X        case LINESPOINTS: fprintf(stderr,"linespoints\n"); break;
  1632. X        case DOTS: fprintf(stderr,"dots\n"); break;
  1633. X    }
  1634. X}
  1635. X
  1636. Xstatic void
  1637. Xshow_range(name,min,max)
  1638. Xchar name;
  1639. Xdouble min,max;
  1640. X{
  1641. X    fprintf(stderr,"\t%crange is [%g : %g]\n",name,min,max);
  1642. X}
  1643. X
  1644. Xstatic void
  1645. Xshow_zero()
  1646. X{
  1647. X    fprintf(stderr,"\tzero is %g\n",zero);
  1648. X}
  1649. X
  1650. Xstatic void
  1651. Xshow_offsets()
  1652. X{
  1653. X    fprintf(stderr,"\toffsets are %g, %g, %g, %g\n",loff,roff,toff,boff);
  1654. X}
  1655. X
  1656. Xstatic void
  1657. Xshow_output()
  1658. X{
  1659. X    fprintf(stderr,"\toutput is sent to %s\n",outstr);
  1660. X}
  1661. X
  1662. Xstatic void
  1663. Xshow_samples()
  1664. X{
  1665. X    fprintf(stderr,"\tsampling rate is %d\n",samples);
  1666. X}
  1667. X
  1668. Xstatic void
  1669. Xshow_size()
  1670. X{
  1671. X    fprintf(stderr,"\tsize is scaled by %g,%g\n",xsize,ysize);
  1672. X}
  1673. X
  1674. Xstatic void
  1675. Xshow_title()
  1676. X{
  1677. X    fprintf(stderr,"\ttitle is \"%s\"\n",title);
  1678. X}
  1679. X
  1680. Xstatic void
  1681. Xshow_xlabel()
  1682. X{
  1683. X    fprintf(stderr,"\txlabel is \"%s\"\n",xlabel);
  1684. X}
  1685. X
  1686. Xstatic void
  1687. Xshow_ylabel()
  1688. X{
  1689. X    fprintf(stderr,"\tylabel is \"%s\"\n",ylabel);
  1690. X}
  1691. X
  1692. Xstatic void
  1693. Xshow_label(tag)
  1694. X    int tag;                /* 0 means show all */
  1695. X{
  1696. X    struct text_label *this_label;
  1697. X    BOOLEAN showed = FALSE;
  1698. X
  1699. X    for (this_label = first_label; this_label != NULL;
  1700. X        this_label = this_label->next) {
  1701. X       if (tag == 0 || tag == this_label->tag) {
  1702. X          showed = TRUE;
  1703. X          fprintf(stderr,"\tlabel %d \"%s\" at %g,%g ",
  1704. X                this_label->tag, this_label->text, 
  1705. X                this_label->x, this_label->y);
  1706. X          switch(this_label->pos) {
  1707. X             case LEFT : {
  1708. X                fprintf(stderr,"left");
  1709. X                break;
  1710. X             }
  1711. X             case CENTRE : {
  1712. X                fprintf(stderr,"centre");
  1713. X                break;
  1714. X             }
  1715. X             case RIGHT : {
  1716. X                fprintf(stderr,"right");
  1717. X                break;
  1718. X             }
  1719. X          }
  1720. X          fputc('\n',stderr);
  1721. X       }
  1722. X    }
  1723. X    if (tag > 0 && !showed)
  1724. X     int_error("label not found", c_token);
  1725. X}
  1726. X
  1727. Xstatic void
  1728. Xshow_arrow(tag)
  1729. X    int tag;                /* 0 means show all */
  1730. X{
  1731. X    struct arrow_def *this_arrow;
  1732. X    BOOLEAN showed = FALSE;
  1733. X
  1734. X    for (this_arrow = first_arrow; this_arrow != NULL;
  1735. X        this_arrow = this_arrow->next) {
  1736. X       if (tag == 0 || tag == this_arrow->tag) {
  1737. X          showed = TRUE;
  1738. X          fprintf(stderr,"\tarrow %d from %g,%g to %g,%g\n",
  1739. X                this_arrow->tag, 
  1740. X                this_arrow->sx, this_arrow->sy,
  1741. X                this_arrow->ex, this_arrow->ey);
  1742. X       }
  1743. X    }
  1744. X    if (tag > 0 && !showed)
  1745. X     int_error("arrow not found", c_token);
  1746. X}
  1747. X
  1748. Xstatic void
  1749. Xshow_grid()
  1750. X{
  1751. X    fprintf(stderr,"\tgrid is %s\n",(grid)? "ON" : "OFF");
  1752. X}
  1753. X
  1754. Xstatic void
  1755. Xshow_key()
  1756. X{
  1757. X    switch (key) {
  1758. X        case -1 : 
  1759. X            fprintf(stderr,"\tkey is ON\n");
  1760. X            break;
  1761. X        case 0 :
  1762. X            fprintf(stderr,"\tkey is OFF\n");
  1763. X            break;
  1764. X        case 1 :
  1765. X            fprintf(stderr,"\tkey is at %g,%g\n",key_x,key_y);
  1766. X            break;
  1767. X    }
  1768. X}
  1769. X
  1770. Xstatic void
  1771. Xshow_polar()
  1772. X{
  1773. X    fprintf(stderr,"\tpolar is %s\n",(polar)? "ON" : "OFF");
  1774. X}
  1775. X
  1776. Xstatic void
  1777. Xshow_tics(showx, showy)
  1778. X    BOOLEAN showx, showy;
  1779. X{
  1780. X    fprintf(stderr,"\ttics are %s\n",(tic_in)? "IN" : "OUT");
  1781. X
  1782. X    if (showx)
  1783. X     show_ticdef(xtics, 'x', &xticdef);
  1784. X    if (showy)
  1785. X     show_ticdef(ytics, 'y', &yticdef);
  1786. X    screen_ok = FALSE;
  1787. X}
  1788. X
  1789. X/* called by show_tics */
  1790. Xstatic void
  1791. Xshow_ticdef(tics, axis, tdef)
  1792. X    BOOLEAN tics;            /* xtics or ytics */
  1793. X    char axis;            /* 'x' or 'y' */
  1794. X    struct ticdef *tdef;    /* xticdef or yticdef */
  1795. X{
  1796. X    register struct ticmark *t;
  1797. X
  1798. X    fprintf(stderr, "\t%c-axis tic labelling is ", axis);
  1799. X    if (!tics) {
  1800. X       fprintf(stderr, "OFF\n");
  1801. X       return;
  1802. X    }
  1803. X
  1804. X    switch(tdef->type) {
  1805. X       case TIC_COMPUTED: {
  1806. X          fprintf(stderr, "computed automatically\n");
  1807. X          break;
  1808. X       }
  1809. X       case TIC_SERIES: {
  1810. X          if (tdef->def.series.end == VERYLARGE)
  1811. X            fprintf(stderr, "series from %g by %g\n", 
  1812. X                  tdef->def.series.start, tdef->def.series.incr);
  1813. X          else
  1814. X            fprintf(stderr, "series from %g by %g until %g\n", 
  1815. X                  tdef->def.series.start, tdef->def.series.incr, 
  1816. X                  tdef->def.series.end);
  1817. X          break;
  1818. X       }
  1819. X       case TIC_USER: {
  1820. X          fprintf(stderr, "list (");
  1821. X          for (t = tdef->def.user; t != NULL; t=t->next) {
  1822. X             if (t->label)
  1823. X               fprintf(stderr, "\"%s\" ", t->label);
  1824. X             if (t->next)
  1825. X               fprintf(stderr, "%g, ", t->position);
  1826. X             else
  1827. X               fprintf(stderr, "%g", t->position);
  1828. X          }
  1829. X          fprintf(stderr, ")\n");
  1830. X          break;
  1831. X       }
  1832. X       default: {
  1833. X          int_error("unknown ticdef type in show_ticdef()", NO_CARET);
  1834. X          /* NOTREACHED */
  1835. X       }
  1836. X    }
  1837. X}
  1838. X
  1839. Xstatic void
  1840. Xshow_term()
  1841. X{
  1842. X    fprintf(stderr,"\tterminal type is %s\n",term_tbl[term].name);
  1843. X}
  1844. X
  1845. Xstatic void
  1846. Xshow_plot()
  1847. X{
  1848. X    fprintf(stderr,"\tlast plot command was: %s\n",replot_line);
  1849. X}
  1850. X
  1851. Xstatic void
  1852. Xshow_autoscale()
  1853. X{
  1854. X    fprintf(stderr,"\tx autoscaling is %s\n",(autoscale_x)? "ON" : "OFF");
  1855. X    fprintf(stderr,"\ty autoscaling is %s\n",(autoscale_y)? "ON" : "OFF");
  1856. X}
  1857. X
  1858. Xstatic void
  1859. Xshow_clip()
  1860. X{
  1861. X    fprintf(stderr,"\tpoint clip is %s\n",(clip_points)? "ON" : "OFF");
  1862. X
  1863. X    if (clip_lines1)
  1864. X      fprintf(stderr,
  1865. X         "\tdrawing and clipping lines between inrange and outrange points\n");
  1866. X    else
  1867. X      fprintf(stderr,
  1868. X         "\tnot drawing lines between inrange and outrange points\n");
  1869. X
  1870. X    if (clip_lines2)
  1871. X      fprintf(stderr,
  1872. X         "\tdrawing and clipping lines between two outrange points\n");
  1873. X    else
  1874. X      fprintf(stderr,
  1875. X         "\tnot drawing lines between two outrange points\n");
  1876. X}
  1877. X
  1878. Xstatic void
  1879. Xshow_format()
  1880. X{
  1881. X    fprintf(stderr, "\tx-axis tic format is \"%s\"\n", xformat);
  1882. X    fprintf(stderr, "\ty-axis tic format is \"%s\"\n", yformat);
  1883. X}
  1884. X
  1885. Xstatic void
  1886. Xshow_logscale()
  1887. X{
  1888. X    if (log_x && log_y)
  1889. X        fprintf(stderr,"\tlogscaling both x and y axes\n");
  1890. X    else if (log_x)
  1891. X        fprintf(stderr,"\tlogscaling x axis\n");
  1892. X    else if (log_y)
  1893. X        fprintf(stderr,"\tlogscaling y axis\n");
  1894. X    else
  1895. X        fprintf(stderr,"\tno logscaling\n");
  1896. X}
  1897. X
  1898. Xstatic void
  1899. Xshow_variables()
  1900. X{
  1901. Xregister struct udvt_entry *udv = first_udv;
  1902. Xint len;
  1903. X
  1904. X    fprintf(stderr,"\n\tVariables:\n");
  1905. X    while (udv) {
  1906. X         len = instring(udv->udv_name, ' ');
  1907. X        fprintf(stderr,"\t%-*s ",len,udv->udv_name);
  1908. X        if (udv->udv_undef)
  1909. X            fputs("is undefined\n",stderr);
  1910. X        else {
  1911. X            fputs("= ",stderr);
  1912. X            disp_value(stderr,&(udv->udv_value));
  1913. X            (void) putc('\n',stderr);
  1914. X        }
  1915. X        udv = udv->next_udv;
  1916. X    }
  1917. X}
  1918. X
  1919. Xvoid                /* used by plot.c */
  1920. Xshow_version()
  1921. X{
  1922. Xextern char version[];
  1923. Xextern char patchlevel[];
  1924. Xextern char date[];
  1925. Xextern char bug_email[];
  1926. Xstatic char *authors[] = {"Thomas Williams","Colin Kelley"}; /* primary */
  1927. Xint x;
  1928. Xlong time();
  1929. X
  1930. X    x = time((long *)NULL) & 1;
  1931. X    fprintf(stderr,"\n\t%s\n\t%sversion %s\n",
  1932. X        PROGRAM, OS, version); 
  1933. X    fprintf(stderr,"\tpatchlevel %s\n",patchlevel);
  1934. X     fprintf(stderr, "\tlast modified %s\n", date);
  1935. X    fprintf(stderr,"\tCopyright (C) 1986, 1987, 1990  %s, %s\n",
  1936. X        authors[x],authors[1-x]);
  1937. X#ifdef __TURBOC__
  1938. X    fprintf(stderr,"\tCreated using Turbo C, Copyright Borland 1987, 1988\n");
  1939. X#endif
  1940. X    fprintf(stderr, "\n\tSend bugs and comments to %s\n", bug_email);
  1941. X}
  1942. END_OF_setshow.c
  1943. if test 41480 -ne `wc -c <setshow.c`; then
  1944.     echo shar: \"setshow.c\" unpacked with wrong size!
  1945. fi
  1946. # end of overwriting check
  1947. fi
  1948. if test ! -d docs ; then
  1949.     echo shar: Creating directory \"docs\"
  1950.     mkdir docs
  1951. fi
  1952. if test -f docs/doc2tex.c -a "${1}" != "-c" ; then 
  1953.   echo shar: Will not over-write existing file \"docs/doc2tex.c\"
  1954. else
  1955. echo shar: Extracting \"docs/doc2tex.c\" \(4694 characters\)
  1956. sed "s/^X//" >docs/doc2tex.c <<'END_OF_docs/doc2tex.c'
  1957. X/*
  1958. X * doc2tex.c  -- program to convert Gnuplot .DOC format to LaTeX document
  1959. X * Also will work for VMS .HLP files. 
  1960. X * Modified by Russell Lang from hlp2ms.c by Thomas Williams 
  1961. X * Extended by David Kotz to support quotes ("), backquotes, tables.
  1962. X *
  1963. X * usage:  doc2tex < file.doc > file.tex
  1964. X *
  1965. X *   where file.doc is a Gnuplot .DOC file, and file.tex will be an
  1966. X *     article document suitable for printing with LaTeX.
  1967. X *
  1968. X * typical usage for GNUPLOT:
  1969. X *
  1970. X *   doc2tex < gnuplot.doc > gnuplot.tex 
  1971. X *   latex gnuplot.tex ; latex gnuplot.tex
  1972. X */
  1973. X
  1974. Xstatic char rcsid[] = "$Id: doc2tex.c,v 1.1 90/01/11 15:44:06 dfk Exp Locker: dfk $";
  1975. X
  1976. X#include <stdio.h>
  1977. X#include <ctype.h>
  1978. X
  1979. X#define MAX_NAME_LEN    256
  1980. X#define MAX_LINE_LEN    256
  1981. X#define TRUE 1
  1982. X#define FALSE 0
  1983. X
  1984. Xtypedef int boolean;
  1985. X
  1986. Xboolean intable = FALSE;
  1987. Xboolean verb = FALSE;
  1988. X
  1989. Xmain()
  1990. X{
  1991. X    init(stdout);
  1992. X    convert(stdin,stdout);
  1993. X    finish(stdout);
  1994. X    exit(0);
  1995. X}
  1996. X
  1997. X
  1998. Xinit(b)
  1999. XFILE *b;
  2000. X{
  2001. X    (void) fputs("\\input{titlepage.tex}\n",b);
  2002. X}
  2003. X
  2004. X
  2005. Xconvert(a,b)
  2006. X    FILE *a,*b;
  2007. X{
  2008. X    static char line[MAX_LINE_LEN];
  2009. X
  2010. X    while (fgets(line,MAX_LINE_LEN,a)) {
  2011. X       process_line(line, b);
  2012. X    }
  2013. X}
  2014. X
  2015. Xprocess_line(line, b)
  2016. X    char *line;
  2017. X    FILE *b;
  2018. X{
  2019. X    switch(line[0]) {        /* control character */
  2020. X       case '?': {            /* interactive help entry */
  2021. X          break;            /* ignore */
  2022. X       }
  2023. X       case '@': {            /* start/end table */
  2024. X          if (intable) {
  2025. X             (void) fputs("\\hline\n\\end{tabular}\n", b);
  2026. X             (void) fputs("\\end{center}\n",b);
  2027. X             intable = FALSE;
  2028. X          } else {
  2029. X             if (verb) {
  2030. X                (void) fputs("\\end{verbatim}\n",b);
  2031. X                verb=FALSE;
  2032. X             } 
  2033. X             (void) fputs("\n\\begin{center}\n", b);
  2034. X             (void) fputs("\\begin{tabular}{|ccl|} \\hline\n", b);
  2035. X             intable = TRUE;
  2036. X          }
  2037. X          /* ignore rest of line */
  2038. X          break;
  2039. X       }
  2040. X       case '#': {            /* latex table entry */
  2041. X          if (intable)
  2042. X            (void) fputs(line+1, b); /* copy directly */
  2043. X          else
  2044. X            fprintf(stderr, "error: # line found outside of table\n");
  2045. X          break;
  2046. X       }
  2047. X       case '%': {            /* troff table entry */
  2048. X          break;            /* ignore */
  2049. X       }
  2050. X       case '\n':            /* empty text line */
  2051. X       case ' ': {            /* normal text line */
  2052. X          if (intable)
  2053. X            break;        /* ignore while in table */
  2054. X          if (line[1] == ' ') {
  2055. X             /* verbatim mode */
  2056. X             if (!verb) {
  2057. X                (void) fputs("\\begin{verbatim}\n",b);
  2058. X                verb=TRUE;
  2059. X             }
  2060. X             (void) fputs(line+1,b); 
  2061. X          } else {
  2062. X             if (verb) {
  2063. X                (void) fputs("\\end{verbatim}\n",b);
  2064. X                verb=FALSE;
  2065. X             } 
  2066. X             puttex(line+1,b);
  2067. X          }
  2068. X          break;
  2069. X       }
  2070. X       default: {
  2071. X          if (isdigit(line[0])) { /* start of section */
  2072. X             if (!intable)    /* ignore while in table */
  2073. X               section(line, b);
  2074. X          } else
  2075. X            fprintf(stderr, "unknown control code '%c' in column 1\n", 
  2076. X                  line[0]);
  2077. X          break;
  2078. X       }
  2079. X    }
  2080. X}
  2081. X
  2082. X/* process a line with a digit control char */
  2083. X/* starts a new [sub]section */
  2084. X
  2085. Xsection(line, b)
  2086. X    char *line;
  2087. X    FILE *b;
  2088. X{
  2089. X    static char string[MAX_LINE_LEN];
  2090. X    int sh_i;
  2091. X
  2092. X    if (verb) {
  2093. X       (void) fputs("\\end{verbatim}\n",b);
  2094. X       verb=FALSE;
  2095. X    } 
  2096. X    (void) sscanf(line,"%d %[^\n]s",&sh_i,string);
  2097. X    switch(sh_i)
  2098. X     {
  2099. X        case 1: 
  2100. X        (void) fprintf(b,"\\section{");
  2101. X        break;
  2102. X        case 2: 
  2103. X        (void) fprintf(b,"\\section{");
  2104. X        break;
  2105. X        case 3:
  2106. X        (void) fprintf(b,"\\subsection{");
  2107. X        break;
  2108. X        case 4: 
  2109. X        (void) fprintf(b,"\\subsubsection{");
  2110. X        break;
  2111. X        default:
  2112. X        case 5: 
  2113. X        (void) fprintf(b,"\\paragraph{");
  2114. X        break;
  2115. X     }
  2116. X    if (islower(string[0]))
  2117. X     string[0] = toupper(string[0]);
  2118. X    puttex(string,b);
  2119. X    (void) fprintf(b,"}\n");
  2120. X}
  2121. X
  2122. X/* put text in string str to file while buffering special TeX characters */
  2123. Xputtex(str,file)
  2124. XFILE *file;
  2125. Xregister char *str;
  2126. X{
  2127. Xregister char ch;
  2128. Xstatic boolean inquote = FALSE;
  2129. X
  2130. X     while( (ch = *str++) != '\0') {
  2131. X         switch(ch) {
  2132. X             case '#':
  2133. X             case '$':
  2134. X             case '%':
  2135. X             case '&':
  2136. X             case '_':
  2137. X             case '{':
  2138. X             case '}':
  2139. X                 (void) fputc('\\',file);
  2140. X                 (void) fputc(ch,file);
  2141. X                 break;
  2142. X             case '\\':
  2143. X                 (void) fputs("$\\backslash$",file);
  2144. X                 break;
  2145. X             case '~':
  2146. X                 (void) fputs("\\~{\\ }",file);
  2147. X                 break;
  2148. X             case '^':
  2149. X                 (void) fputs("\\verb+^+",file);
  2150. X                 break;
  2151. X             case '>':
  2152. X             case '<':
  2153. X             case '|':
  2154. X                 (void) fputc('$',file);
  2155. X                 (void) fputc(ch,file);
  2156. X                 (void) fputc('$',file);
  2157. X                 break;
  2158. X             case '"': 
  2159. X                 /* peek at next character: if space, end of quote */
  2160. X                 if (*str == NULL || isspace(*str) || ispunct(*str))
  2161. X                   (void) fputs("''", file);
  2162. X                 else
  2163. X                   (void) fputs("``", file);
  2164. X                 break;
  2165. X             case '`':    /* backquotes mean boldface */
  2166. X                 if (inquote) {
  2167. X                    fputs("}", file);
  2168. X                    inquote = FALSE;
  2169. X                 } else {
  2170. X                    fputs("{\\bf ", file);
  2171. X                    inquote = TRUE;
  2172. X                 }
  2173. X                 break;
  2174. X             default:
  2175. X                 (void) fputc(ch,file);
  2176. X                 break;
  2177. X         }
  2178. X     }
  2179. X}
  2180. X
  2181. X
  2182. Xfinish(b)
  2183. XFILE *b;
  2184. X{
  2185. X    (void) fputs("\\end{document}\n",b);
  2186. X}
  2187. END_OF_docs/doc2tex.c
  2188. if test 4694 -ne `wc -c <docs/doc2tex.c`; then
  2189.     echo shar: \"docs/doc2tex.c\" unpacked with wrong size!
  2190. fi
  2191. # end of overwriting check
  2192. fi
  2193. if test -f docs/titlepage.ms -a "${1}" != "-c" ; then 
  2194.   echo shar: Will not over-write existing file \"docs/titlepage.ms\"
  2195. else
  2196. echo shar: Extracting \"docs/titlepage.ms\" \(290 characters\)
  2197. sed "s/^X//" >docs/titlepage.ms <<'END_OF_docs/titlepage.ms'
  2198. X.nr HM 3.2i
  2199. X.TL
  2200. XGNUPLOT
  2201. X.br
  2202. XAn Interactive Plotting Program
  2203. X.sp
  2204. X.AU
  2205. XThomas Williams & Colin Kelley
  2206. X.br
  2207. XJohn Campbell, David Kotz, and Russell Lang (Version 2.0)
  2208. X.AI
  2209. Xpixar!info-gnuplot@sun.com
  2210. X\*(DY
  2211. X.br
  2212. X
  2213. X
  2214. X
  2215. X
  2216. X
  2217. X
  2218. X
  2219. X
  2220. X
  2221. X
  2222. X
  2223. X
  2224. X
  2225. X
  2226. X
  2227. X
  2228. X
  2229. X
  2230. X
  2231. X
  2232. X
  2233. XThis manual is for GNUPLOT version 2.0.
  2234. X.AB no
  2235. X.AE
  2236. X.LP
  2237. X.nr HM 1.2i
  2238. END_OF_docs/titlepage.ms
  2239. if test 290 -ne `wc -c <docs/titlepage.ms`; then
  2240.     echo shar: \"docs/titlepage.ms\" unpacked with wrong size!
  2241. fi
  2242. # end of overwriting check
  2243. fi
  2244. if test -f docs/titlepage.tex -a "${1}" != "-c" ; then 
  2245.   echo shar: Will not over-write existing file \"docs/titlepage.tex\"
  2246. else
  2247. echo shar: Extracting \"docs/titlepage.tex\" \(760 characters\)
  2248. sed "s/^X//" >docs/titlepage.tex <<'END_OF_docs/titlepage.tex'
  2249. X\documentstyle{article}
  2250. X\setlength{\textwidth}{6.25in}
  2251. X\setlength{\oddsidemargin}{0.5cm}
  2252. X\setlength{\topmargin}{-0.5in}
  2253. X\setlength{\textheight}{9in}
  2254. X\setlength{\parskip}{1ex}
  2255. X\setlength{\parindent}{0pt}
  2256. X\begin{document}
  2257. X
  2258. X\pagestyle{empty}
  2259. X   \rule{0in}{3in}
  2260. X   \begin{center}
  2261. X   {\huge\bf GNUPLOT}\\
  2262. X   \vspace{3ex}
  2263. X   {\Large An Interactive Plotting Program}\\
  2264. X   \vspace{2ex}
  2265. X   \large
  2266. X   Thomas Williams \& Colin Kelley\\
  2267. X   \vspace{2ex}
  2268. X   Version 2.0: \\
  2269. X   John Campbell, David Kotz, and Russell Lang\\
  2270. X   \vspace{2ex}
  2271. X   \verb+pixar!info-gnuplot@sun.com+
  2272. X
  2273. X   \vfill
  2274. X   {\small This manual is for GNUPLOT version 2.0.}
  2275. X
  2276. X   \end{center}
  2277. X\newpage
  2278. X
  2279. X\tableofcontents
  2280. X\newpage
  2281. X
  2282. X\setcounter{page}{1}
  2283. X\pagestyle{myheadings}
  2284. X\markboth{GNUPLOT 2.0}{GNUPLOT 2.0}
  2285. X
  2286. END_OF_docs/titlepage.tex
  2287. if test 760 -ne `wc -c <docs/titlepage.tex`; then
  2288.     echo shar: \"docs/titlepage.tex\" unpacked with wrong size!
  2289. fi
  2290. # end of overwriting check
  2291. fi
  2292. echo shar: End of shell archive.
  2293. exit 0
  2294.  
  2295.